﻿<!DOCTYPE HTML>
<html lang="zh">
<head>
<title>WinGetList - 语法 &amp; 使用 | AutoHotkey v2</title>
<meta name="description" content="The WinGetList function returns the unique ID numbers of all existing windows that match the specified criteria." />
<meta name="ahk:equiv-v1" content="commands/WinGet.htm#List" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link href="../static/theme.css" rel="stylesheet" type="text/css" />
<script src="../static/content.js" type="text/javascript"></script>
<script type="text/javascript">$(function(){0<=window.navigator.userAgent.toLowerCase().indexOf("ucbrowser")&&CaoNiMaDeUc()})</script>
</head>
<body>

<h1>WinGetList</h1>

<p>Returns the unique ID numbers of all existing windows that match the specified criteria.</p>

<pre class="Syntax">List := <span class="func">WinGetList</span>(<span class="optional">WinTitle, WinText, ExcludeTitle, ExcludeText</span>)</pre>

<h2 id="Parameters">参数</h2>
<dl>
    <dt>WinTitle</dt>
    <dd>
        <p>类型: <a href="../Concepts.htm#strings">字符串</a>, <a href="../Concepts.htm#numbers">整数</a>或<a href="../Objects.htm">对象</a></p>
        <p>识别目标窗口的窗口标题或其他条件. 请参阅 <a href="../misc/WinTitle.htm">WinTitle</a>.</p>
    </dd>
    <dt>WinText</dt>
    <dd>
        <p>类型: <a href="../Concepts.htm#strings">字符串</a></p>
        <p>如果存在, 此参数必须是目标窗口的单个文本元素的子字符串(和内置的 Window Spy 工具显示的一样). 如果 <a href="DetectHiddenText.htm">DetectHiddenText</a> 为 ON, 那么会检测隐藏文本元素.</p>
    </dd>
    <dt>ExcludeTitle</dt>
    <dd>
        <p>类型: <a href="../Concepts.htm#strings">字符串</a></p>
        <p>标题中含有此参数值的窗口将被排除.</p>
    </dd>
    <dt>ExcludeText</dt>
    <dd>
        <p>类型: <a href="../Concepts.htm#strings">字符串</a></p>
        <p>文本中含有此参数值的窗口将被排除.</p>
    </dd>
</dl>

<h2 id="Return_Value">返回值</h2>
<p>类型: <a href="../Concepts.htm#objects">数组</a></p>
<p>This function returns an array containing the <a href="../misc/WinTitle.htm#ahk_id">window handles (HWND)</a> of all existing windows that match the specified parameters. If there is no matching window, an empty array is returned.</p>
<p>例如, if the return value is assigned to a variable named <code>List</code> and two matching windows are discovered, <code>List[1]</code> contains the ID of the first window, <code>List[2]</code> contains the ID of the second window, and <code>List.<a href="../objects/Array.htm#Length">Length</a></code> returns the number 2.</p>
<p>Windows are retrieved in order from topmost to bottommost (according to how they are stacked on the desktop).</p>

<h2 id="Remarks">备注</h2>
<p>To retrieve all windows on the entire system, omit all four title/text parameters.</p>
<p>鼠标光标下的窗口的 ID 可以使用 <a href="MouseGetPos.htm">MouseGetPos</a> 来获取.</p>
<p>窗口标题和文本是区分大小写的. 除非 <a href="DetectHiddenWindows.htm">DetectHiddenWindows</a> 被打开, 否则不会检测隐藏窗口.</p>

<h2 id="Related">相关</h2>
<p><a href="WinGetCount.htm">WinGetCount</a>, <a href="Win.htm">Win functions</a>, <a href="Control.htm">Control functions</a></p>

<h2 id="Examples">示例</h2>
<div class="ex" id="ExBasic">
<p><a href="#ExBasic">#1</a>: This will visit all windows on the entire system and display info about each of them:</p>
<pre>id := WinGetList(,, "Program Manager")
Loop id.Length
{
    this_id := id[A_Index]
    WinActivate "ahk_id " this_id
    this_class := WinGetClass("ahk_id " this_id)
    this_title := WinGetTitle("ahk_id " this_id)
    Result := MsgBox(
    (
        "Visiting All Windows
        " A_Index " of " id.Length "
        ahk_id " this_id "
        ahk_class " this_class "
        " this_title "

        Continue?"
    ),, 4)
    if (Result = "No")
        break
}</pre>
</div>

</body>
</html>